package CTRLayer;
import ModelLayer.Salesman;
import DBLayer.DBSalesman;

public class SalesmanCTR 
{
	private DBSalesman dbSalesman;
	
	public SalesmanCTR()
	{
		dbSalesman = new DBSalesman();
	}
	
	public Salesman createSalesman(String name, String ssn, String phoneno, String email, String address, String zipCode, String salesmanID, String paymentLevel)
	{
		Salesman salesman = new Salesman(name, ssn, phoneno, email, address, zipCode, salesmanID, paymentLevel);
		return salesman;
	}
	
	public void insertSalesman(String name, String ssn, String phoneno, String email, String address, String zipCode, String salesmanID, String paymentLevel)
	{
		Salesman salesman = createSalesman(name, ssn, phoneno, email, address, zipCode, salesmanID, paymentLevel);
		dbSalesman.insertSalesman(salesman);
	}
	
	public Salesman getSalesman(String salesmanID, boolean retrieveAssociations)
	{
		Salesman salesman = dbSalesman.findSalesman(salesmanID, retrieveAssociations);
		return salesman;
	}
	
	public void updateSalesman(String salesmanID, String newName, String newSsn, String newPhoneno, String newEmail, String newAddress, String newZipCode, String newSalesmanID, String newPaymentLevel)
	{
		Salesman salesman = createSalesman(newName, newSsn, newPhoneno, newEmail, newAddress, newZipCode, newSalesmanID, newPaymentLevel);
		dbSalesman.updateSalesman(salesman, salesmanID);
	}
	
	public void deleteSalesman(String salesmanID)
	{
		dbSalesman.removeSalesman(salesmanID);
	}
}
